package com.lushuan.ch11_springboot_test.demo.interface_and_abstract;

// 抽象类
abstract class Animal2 {
    protected String name;

    public Animal2(String name) {
        this.name = name;
    }

    public abstract void eat(); // 抽象方法

    public void sleep() { // 具体方法
        System.out.println(name + " is sleeping...");
    }

    public static void breathe() { // 静态方法
        System.out.println("Breathing...");
    }
}

// 继承抽象类
class Cat extends Animal2 {
    public Cat(String name) {
        super(name);
    }

    @Override
    public void eat() {
        System.out.println(name + " is eating...");
    }
}

public class AbstractClassExample {
    public static void main(String[] args) {
        Cat cat = new Cat("Tom");
        cat.eat(); // 输出: Tom is eating...
        cat.sleep(); // 输出: Tom is sleeping...
        Animal2.breathe(); // Breathing...
    }
}
